package com.pinyoumei.app.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.pinyoumei.app.R;
import com.pinyoumei.app.bean.TaoBaoOrderBean;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.math.BigDecimal;
import java.util.List;

/**
 * Created by Administrator on 2020-12-15.
 * --------- 日期 ------- 维护人 ------------ 变更内容 --------
 * 2020-12-15        Administrator             新增Person类
 * 2020-12-15        Administrator             增加sex属性
 */
public class TaoBaoOrderAdapter extends BaseQuickAdapter<TaoBaoOrderBean.ResultBean.OrderListBean, BaseViewHolder> {




    public TaoBaoOrderAdapter(int layoutResId, @Nullable List<TaoBaoOrderBean.ResultBean.OrderListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, TaoBaoOrderBean.ResultBean.OrderListBean item) {
        RequestOptions placeholder = new RequestOptions().placeholder(R.mipmap.ic_error_loading);
        ImageView imageView =  helper.getView(R.id.iv_bg);

        Glide.with(mContext).load(item.getSku_img()+"").apply(placeholder).into(imageView);


        helper.setText(R.id.tv_order_no," 订单编号：" + item.getOrder_no());
        helper.setText(R.id.tv_orderStatusDesc,item.getOrderStatusDesc());
        helper.setText(R.id.tv_sku_name,item.getSku_name());
        helper.setText(R.id.tv_price,"¥" + item.getPrice());
        helper.setText(R.id.tv_sku_num,"x" + item.getSku_num());

        helper.setText(R.id.tv_order_time,"创建时间：" + item.getOrder_time());


        BigDecimal b1 = new BigDecimal(Double.valueOf(item.getSku_num()));
        BigDecimal b2 = item.getPrice();



        helper.setText(R.id.tv_all_price,"总价格：¥" +   b1.multiply(b2).doubleValue());
    }
}
